Click or drag to resize

AskiaField Communication Library Documentation

This documentation help you quick start using the AskiaField Communication Library and provide the full API reference.

This topic contains the following sections:

What's the AskiaField Communication Library?

AskiaField Communication Library (AskiaFieldCom.dll) is a .Net library providing an access to AskiaField through the AskiaField databases and AskiaField API socket.

It's intended to be used by the AskiaPortal modules that require an access to AskiaField.

Features

AskiaField Communication Library provide the following non-exhaustive list of features:

  • Connection to the AskiaField databases and socket (allow connection to several different AskiaField servers).

  • Context of execution (per web query or per relevant action)

  • Provide management of agents (users)

  • Provide management of surveys

Code styling

Interfaces vs. Classes

Most of the objects in the AskiaFieldCom Library are only available through their interfaces.

As many as possible, it avoid to expose classes and constructors.

For several reasons we feel it's good pattern to be future-proof and to do seamless improvements.

Static factories

To instantiate an object, AskiaFieldCom Library uses static object factories such as FieldConnectionFactory, ModuleFactory,ContextFactory, AgentFactory, ...

C#
IAgent agent = FindById.FindById(context, id);

Avoid throwing exception

AskiaFieldCom Library tries as much as possible to not throw exceptions.

try{} catch {} blocks degrade performances and are necessary when an API intensively throw exceptions.

Instead of throwing, AskiaFieldCom Library will, most of the time, returns a result in form of IResult or IResultT.

C#
IResult result = object.Method();
if (!result.Success)
{
    // Use the result.Exception,
    // result.Exception.Message
    // or
    // throw result.Exception;
}
C#
IResult<string> result = object.Method();
if (!result.Success)
{
    // Use the result.Exception,
    // result.Exception.Message
    // or
    // throw result.Exception;
}
// Use the value returned by the method
string value = result.Value;